package com.eh.observer.observer.impl;

import com.eh.observer.dto.Event;
import com.eh.observer.ext.DisplayElement;
import com.eh.observer.observer.Observer;

/**
 * Created by David on 2016/4/23.
 */
public class CurrentConditionDisplay implements Observer, DisplayElement {
    private float temperature;
    private float humidity;

    @Override
    public void display() {
        System.out.println(String.format("当前天气状况: 温度：【%.2f】, 湿度：【%.2f】.", temperature, humidity));
    }

    @Override
    public void update(Event event) {
        this.temperature = event.getTemperature();
        this.humidity = event.getHumidity();
        display();
    }
}
